#include "Query.h"
#include "QueryHandler.h"

std::vector <Operator *> Operators;

static void clearOps()
{
	for (std::vector <Operator *> :: iterator i = Operators.begin(); i != Operators.end(); i++)
	{
		delete *i;
	}
};

int main(int argc, char **argv)
{
	if (argc != 2)
	{
		std::cout << "Invalid argument.\n Use 'search_engine input_file_name' commandline instead.\nClosing.";
		return 1;
	}
	
	Query *q;
	QueryHandler h;

	q = h.loadQueryFromFile(argv[1]);

	if (!q)
		return 1;

	h.printQuery("output.txt", q);

	h.search(q);
		
	q->clear();
	clearOps();

	return 0;
}
